#ifndef __DIRECTORY_HPP__
#define __DIRECTORY_HPP__

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <unordered_map>

class directory
{
public:
    directory(const std::string file_name)
    {
        std::ifstream ifs(file_name.c_str());
        std::string eng, ch;
        std::string line;
        while (std::getline(ifs, line))
        {
            int pos = line.find(':');
            ch = line.substr(0 , pos) , eng = line.substr(pos + 1);
            ch_toeng_[ch] = eng;
            eng_toch_[eng] = ch;
        }
    }

    std::string find(const std::string word)
    {
        if(ch_toeng_.count(word)) return ch_toeng_[word];
        if(eng_toch_.count(word)) return eng_toch_[word];

        return "NO Wold !!! ";
    }


private:
    std::unordered_map<std::string, std::string> ch_toeng_; // 汉译英
    std::unordered_map<std::string, std::string> eng_toch_; // 英译汉
};

#endif